package cn.edu.bupt.scidata.service.impl;

import cn.edu.bupt.scidata.service.IDSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class PaperIdRedis {
    @Autowired
    @Qualifier("myredisTemplate")
    RedisTemplate myredisTemplete;

    @Autowired
    IDSearch idSearch;

    public List<Integer> getids(String keyword, String lang) {
        String key = "paperid"+keyword + lang;
        if (myredisTemplete.opsForList().size(key)==0) {
            myredisTemplete.opsForList().rightPushAll(key, idSearch.getids(keyword, lang));
        }
        long len=myredisTemplete.opsForList().size(key);
        return myredisTemplete.opsForList().range(key,0,len-1);
    }
}
